package com.example.utils;

import com.example.utils.image.RedisUtil;


/**
 * @author LEI
 * Created by LEI on 2020/3/16.
 */
public class QQManagerUtils {

    public static boolean isSaveQQMessage(){
        String str = RedisUtil.getString("coolq:qqManager:isSaveQQMessage");
        if(StringUtils.isEmpty(str))return false;
        return str.equals("1");
    }

    /**该qq群是否允许保存消息
     * @param fromGroup
     * @return
     */
    public static boolean isPassQQGroup(Long fromGroup){
        String str = RedisUtil.getString("coolq:qqManager:saveQQMessageGroup");
        if(StringUtils.isEmpty(str))return false;
        return str.contains(fromGroup.toString());
    }

    /**是否回复消息
     *
     * @return
     */
    public static boolean isReplyQQMessage(){
        String str = RedisUtil.getString("coolq:qqManager:isReplyQQMessage");
        if(StringUtils.isEmpty(str))return false;
        return str.equals("1");
    }

    /**设置是否回复消息
     * @param flag
     */
    public static void setReplyQQMessage(boolean flag){
        RedisUtil.setString("coolq:qqManager:isReplyQQMessage",flag?"1":"0");
    }

    /**回复消息的qq群
     * @param fromGroup
     * @return
     */
    public static boolean isPassReplyGroupMessage(Long fromGroup){
        String str = RedisUtil.getString("coolq:qqManager:isPassReplyGroupMessage");
        if(StringUtils.isEmpty(str))return false;
        return str.contains(fromGroup.toString());
    }

    /**是否管理员
     * @param fromQQ
     * @return
     */
    public static boolean isManager(Long fromQQ){
        String str = RedisUtil.getString("coolq:qqManager:managerUser");
        if(StringUtils.isEmpty(str))return false;
        return str.contains(fromQQ.toString());
    }
}
